import React, { Component } from 'react'
import { inject, observer } from 'mobx-react';

@inject('todo')
@observer
class TodoList extends Component {
  render() {
    const { fiterTodo, todoDelete, changeCompleted } = this.props.todo;
    return (
      <section className="main">
        <input className="toggle-all" type="checkbox" />
        <ul className="todo-list">
          {
            fiterTodo.map((todo, index) => (
              <li key={todo.taskName} className={todo.isCompleted ? 'completed' : ''} >
                <div className="view">
                  <input 
                    checked={todo.isCompleted} 
                    className="toggle"
                    type="checkbox"
                    onChange={e=>changeCompleted(index, e.target.checked)}
                  />
                  <label>{todo.taskName}</label>
                  <button className="destroy" onClick={() => todoDelete(index)}></button>
                </div>
                <input className="edit" />
              </li>
            ))
          }
        </ul>
      </section>
    )
  }
}

export default TodoList
